{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "lovely-andorra",
   "metadata": {},
   "outputs": [],
   "source": [
    "from code.ftquoteapi import quoteapi as quote\n",
    "import imp\n",
    "from futu import *\n",
    "#imp.reload(quoteapi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "furnished-sword",
   "metadata": {},
   "outputs": [],
   "source": [
    "context = quote()"
   ]
  },
  {
   "cell_type": "raw",
   "id": "liked-export",
   "metadata": {},
   "source": [
    "中文\t英文\n",
    "全部\tAll\n",
    "沪深\tCN\n",
    "港股\tHK\n",
    "美股\tUS\n",
    "期权\tOptions\n",
    "港股期权\tHK options\n",
    "美股期权\tUS options\n",
    "特别关注\tStarred\n",
    "期货\tFutures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "global-plaza",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 11:45:45,413 [open_context_base.py] _socket_reconnect_and_wait_ready:255: Start connecting: host=127.0.0.1; port=11111;\n",
      "2021-03-01 11:45:45,416 [open_context_base.py] on_connected:344: Connected : conn_id=1; \n",
      "2021-03-01 11:45:45,420 [open_context_base.py] _handle_init_connect:445: InitConnect ok: conn_id=1; info={'server_version': 500, 'login_user_id': 716900, 'conn_id': 6771998858079501381, 'conn_key': 'BEBB3025D892349F', 'conn_iv': '2C531ED40856165C', 'keep_alive_interval': 10, 'is_encrypt': False};\n",
      "2021-03-01 11:45:45,838 [network_manager.py] work:366: Close: conn_id=1\n"
     ]
    }
   ],
   "source": [
    "context.init_context()\n",
    "ret, df = context.get_user_security_group()\n",
    "context.closecontext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "matched-recorder",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>group_name</th>\n",
       "      <th>group_type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>新加坡</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>债券</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>期权</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>期货</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>港股期权</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>特别关注</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>美股期权</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>美股</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>港股</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>沪深</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>全部</td>\n",
       "      <td>SYSTEM</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   group_name group_type\n",
       "0         新加坡     SYSTEM\n",
       "1          债券     SYSTEM\n",
       "2          期权     SYSTEM\n",
       "3          期货     SYSTEM\n",
       "4        港股期权     SYSTEM\n",
       "5        特别关注     SYSTEM\n",
       "6        美股期权     SYSTEM\n",
       "7          美股     SYSTEM\n",
       "8          港股     SYSTEM\n",
       "9          沪深     SYSTEM\n",
       "10         全部     SYSTEM"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "stainless-northern",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 11:50:42,171 [open_context_base.py] _socket_reconnect_and_wait_ready:255: Start connecting: host=127.0.0.1; port=11111;\n",
      "2021-03-01 11:50:42,174 [open_context_base.py] on_connected:344: Connected : conn_id=8; \n",
      "2021-03-01 11:50:42,177 [open_context_base.py] _handle_init_connect:445: InitConnect ok: conn_id=8; info={'server_version': 500, 'login_user_id': 716900, 'conn_id': 6772000102761794087, 'conn_key': '618CF526D8922806', 'conn_iv': '68DA2C7348565685', 'keep_alive_interval': 10, 'is_encrypt': False};\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   group_name group_type\n",
      "0         新加坡     SYSTEM\n",
      "1          债券     SYSTEM\n",
      "2          期权     SYSTEM\n",
      "3          期货     SYSTEM\n",
      "4        港股期权     SYSTEM\n",
      "5        特别关注     SYSTEM\n",
      "6        美股期权     SYSTEM\n",
      "7          美股     SYSTEM\n",
      "8          港股     SYSTEM\n",
      "9          沪深     SYSTEM\n",
      "10         全部     SYSTEM\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 11:50:42,192 [network_manager.py] work:366: Close: conn_id=8\n"
     ]
    }
   ],
   "source": [
    "context.init_context()\n",
    "ret, df = context.get_user_security_group(UserSecurityGroupType.SYSTEM)  #NONE  CUSTOM  SYSTEM\n",
    "print(df)\n",
    "context.closecontext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "annoying-merchant",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 11:39:31,367 [network_manager.py] work:366: Close: conn_id=1\n"
     ]
    }
   ],
   "source": [
    "context.init_context()\n",
    "ret, df = context.get_user_security()\n",
    "context.closecontext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "religious-mystery",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
